package paf.model;

public class Connection {
	private boolean bolRead;
	private boolean bolDelete;
	private boolean bolUpdate;
	private boolean bolCreate;
	private Class conClass;
	private UseCase conUseCase;
	
	protected Connection(Class connectedClass, UseCase connectedUseCase){
		this.setConnectedClass(connectedClass);
		this.setConnectedUseCase(connectedUseCase);
	}

	public boolean isRead() {
		return bolRead;
	}

	public void setRead(boolean read) {
		this.bolRead = read;
	}

	public boolean isDelete() {
		return bolDelete;
	}

	public void setDelete(boolean delete) {
		this.bolDelete = delete;
	}

	public boolean isUpdate() {
		return bolUpdate;
	}

	public void setUpdate(boolean update) {
		this.bolUpdate = update;
	}

	public boolean isCreate() {
		return bolCreate;
	}

	public void setCreate(boolean create) {
		this.bolCreate = create;
	}

	public Class getConnectedClass() {
		return conClass;
	}

	public void setConnectedClass(Class connectedClass) {
		this.conClass = connectedClass;
	}

	public UseCase getConnectedUseCase() {
		return conUseCase;
	}

	public void setConnectedUseCase(UseCase usecase) {
		this.conUseCase = usecase;
	}
	
	@Override
	public String toString() {
		String crud = "";
		if(bolCreate) crud += "C";
		if(bolRead) crud += "R";
		if(bolUpdate) crud += "U";
		if(bolDelete) crud += "D";
		return this.conClass + " - " + this.conUseCase + ": " + crud;
	}

}
